<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./vue.js"></script>
    <style></style>
  </head>
  <body>
    <div id="app">
      <!-- 
        :value="userName"  数据影响视图
        @input="userName=$event.target.value"  视图影响数据
        数据的双向绑定
       -->
      <input
        type="text"
        :value="userName"
        @input="userName=$event.target.value"
      />
      <input type="text" v-model="userName" />
      <button @click="tip">提交</button>
    </div>
  </body>
  <script>
    let app = Vue.createApp({
      data() {
        return {
          userName: "张三",
        };
      },
      methods: {
        tip() {
          alert(this.userName);
          this.userName = "";
        },
      },
    });
    app = app.mount("#app");
  </script>
</html>
